package uabc.arduino.componentes;

import java.awt.BorderLayout;

import javax.swing.ButtonGroup;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.util.ArrayList;

import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class AddChartDialog extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private boolean acepto;
	private AddChartPanel pnlConfiguracion;

	/**
	 * Create the dialog.
	 */
	public AddChartDialog(AddChartPanel panel) {
		setBounds(100, 100, 515, 320);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);

		pnlConfiguracion = panel;
		pnlConfiguracion.setBounds(0, 0, 480, 235);
		contentPanel.add(pnlConfiguracion);

		JButton btnCancelar = new JButton("Cancelar");
		btnCancelar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		btnCancelar.setBounds(368, 254, 89, 23);
		contentPanel.add(btnCancelar);

		JButton btnAceptar = new JButton("Aceptar");
		btnAceptar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (pnlConfiguracion.isImagen() || pnlConfiguracion.isTipoSelected()) {
					if (pnlConfiguracion.isConfiguracionSelected()) {
						if (pnlConfiguracion.isTipoOsciloscopio()) {
							if (pnlConfiguracion.isPeriodoCorrecto()) {
								acepto = true;
								setVisible(false);
							} else {
								JOptionPane.showMessageDialog(pnlConfiguracion,
										"Ingrese correctamente el periodo",
										"Error",
										JOptionPane.INFORMATION_MESSAGE);
							}
						} else {
							acepto = true;
							setVisible(false);
						}
					} else {
						JOptionPane.showMessageDialog(pnlConfiguracion,
								"Seleccione seleccione una Configuracion",
								"Error", JOptionPane.INFORMATION_MESSAGE);
					}
				} else {
					JOptionPane.showMessageDialog(pnlConfiguracion,
							"Seleccione el tipo de Grafica", "Error",
							JOptionPane.INFORMATION_MESSAGE);
				}
			}
		});
		btnAceptar.setBounds(262, 254, 89, 23);
		contentPanel.add(btnAceptar);
		panel.setLayout(null);

	}

	public boolean isAcepto() {
		return acepto;
	}

	public void setAcepto(boolean acepto) {
		this.acepto = acepto;
	}
}
